package com.ctshk.sapp.certificate.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.certificate.dto.CertificateAcceptDTO;
import com.ctshk.rpc.certificate.dto.CertificateHkMacauCarDTO;
import com.ctshk.rpc.certificate.req.CertificateAcceptPageReq;
import com.ctshk.rpc.certificate.req.CertificateHkMacauCarReq;
import com.ctshk.rpc.certificate.req.ProcCommonCertificateReq;
import com.ctshk.rpc.certificate.service.ICertificateHkMacauCarService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 港澳私人小汽车入出内地移位牌证业务 前端控制器
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-03-25
 */
@Api(value = "港澳私人小汽车入出内地移位牌证",tags = "港澳私人小汽车入出内地移位牌证")
@RestController
@RequestMapping("/certificate-hk-macau-car")
public class CertificateHkMacauCarController extends BaseController {
    
    @DubboReference
    private ICertificateHkMacauCarService hkMacauCarService;

    @ApiOperation(value = "港澳私人小汽车入出内地移位牌证信息详情", notes = "港澳私人小汽车入出内地移位牌证信息详情")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "查询证件信息详情", operDesc = "查询证件信息详情")
    @GetMapping(value = "/detail")
    public Result<CertificateHkMacauCarDTO> queryDetail(@RequestParam(value = "id") Long id) {
        return Result.success(hkMacauCarService.queryDetail(id));
    }

    @ApiOperation(value = "修改港澳私人小汽车入出内地移位牌证信息", notes = "修改港澳私人小汽车入出内地移位牌证信息")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.UPDATE, operTitle = "修改证件信息", operDesc = "修改证件信息")
    @PostMapping("/update")
    public Result updateHkMacauCar(@RequestBody @Valid CertificateHkMacauCarReq certificateHkMacauCarReq) {
        Long userId = getCurrentUser(getRequest()).getId();
        return hkMacauCarService.updateHkMacauCar(certificateHkMacauCarReq, userId);
    }

    @ApiOperation(value = "处理港澳私人小汽车入出内地移位牌证预约信息", notes = "处理港澳私人小汽车入出内地移位牌证预约信息")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.UPDATE, operTitle = "处理港澳私人小汽车入出内地移位牌证预约信息", operDesc = "处理港澳私人小汽车入出内地移位牌证预约信息")
    @PostMapping("/proc-reserve")
    public Result procReserveHkMacauCar(@RequestBody @Valid ProcCommonCertificateReq procReserveHkMacauCarReq) {
        Long userId = getCurrentUser(getRequest()).getId();
        return hkMacauCarService.procReserveHkMacauCar(procReserveHkMacauCarReq, userId);
    }

    @ApiOperation(value = "证件受理列表", notes = "证件受理列表")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "证件受理列表", operDesc = "证件受理列表")
    @PostMapping("/accept-list")
    public Result<PageResponse<CertificateAcceptDTO>> queryCertificateAcceptList(@RequestBody CertificateAcceptPageReq acceptPageReq) {
        PageResponse<CertificateAcceptDTO> response = hkMacauCarService.queryCertificateAcceptList(acceptPageReq);
        return Result.success(response);
    }
}
